package day15;

import day4.BankAcc;

import java.beans.XMLDecoder;
import java.io.FileInputStream;
import java.util.List;

/**
 * @author oldliu
 * @since 1.0
 */
public class EncoderXMLObj {
    public static void main(String[] args) {
//        List<BankAcc> list = new ArrayList<>();
//        list.add(new BankAcc("hf--1", "老吴", "123", "shanghai", 1000000.0F));
//        list.add(new BankAcc("hf--2", "小刘", "1243", "shanghai", 100030.0F));
//        list.add(new BankAcc("hf--3", "小李", "1523", "nanjing", 60000.0F));
//        list.add(new BankAcc("hf--4", "老张", "623", "shanghai", 1000.0F));
//        list.add(new BankAcc("hf--3", "小马", "282938282", "安庆", 7676666.0F));
//
//        try {
//            XMLEncoder xd=new XMLEncoder(new FileOutputStream("bank.xml"));
//            xd.writeObject(list);
//            xd.close();
//        } catch (Exception e) {
//            e.printStackTrace();
//        }
        try {
            XMLDecoder xe=new XMLDecoder(new FileInputStream("bank.xml"));
            List<BankAcc> list = (List<BankAcc>) xe.readObject();
            System.out.println(list);
            xe.close();
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}
